package com.wondersgroup.hs.mobile.report.support.submitJob;

import com.fr.base.ParameterMapNameSpace;
import com.fr.data.ClassSubmitJob;
import com.fr.data.SubmitJob;
import com.fr.data.TableDataSource;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.report.report.Report;
import com.fr.report.write.AbstractSubmitVisitor;
import com.fr.report.write.MismatchException;
import com.fr.script.Calculator;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.write.DMLReport;
import com.fr.write.WClassSubmiterProvider;

import java.sql.Connection;
import java.util.Map;

/**
 * Created by zarra on 2016/12/29.
 */
public class NursingDocSubmiter extends AbstractSubmitVisitor implements WClassSubmiterProvider {
    private SubmitJob submitJob = null;

    public NursingDocSubmiter() {
    }

    public void execute(Report var1, TableDataSource var2, Map var3) throws Exception {
        try {
            super.execute(var1, var2, var3);
        } catch (MismatchException var6) {
            return;
        }

        if(this.submitJob != null) {
            Calculator var4 = Calculator.createCalculator();
            var4.setAttribute(DMLReport.class, var1);
            var4.setAttribute(TableDataSource.class, var2);
            ParameterMapNameSpace var5 = ParameterMapNameSpace.create(var3);
            var4.pushNameSpace(var5);
            this.submitJob.doJob(var4);
        }

    }

    public SubmitJob getSubmitJob() {
        return this.submitJob;
    }

    public void setSubmitJob(SubmitJob var1) {
        this.submitJob = var1;
    }

    public Connection getConnection() {
        return null;
    }

    public void setConnection(Connection var1) {
    }

    public void readXML(XMLableReader var1) {
        super.readXML(var1);
        if(var1.isChildNode()) {
            String var2 = var1.getTagName();
            if("SubmitJob".equals(var2)) {
                this.submitJob = (SubmitJob) GeneralXMLTools.readXMLable(var1);
            } else if("ClassSubmitJob".equals(var1.getTagName())) {
                ClassSubmitJob var3 = new ClassSubmitJob();
                var1.readXMLObject(var3);
                this.submitJob = var3;
            }
        }

    }

    public void writeXML(XMLPrintWriter var1) {
        super.writeXML(var1);
        if(this.submitJob != null) {
            GeneralXMLTools.writeXMLable(var1, this.submitJob, "SubmitJob");
        }

    }
}
